package com.gupao.gupaoeduvippattern.javaBase.thread.day01_3;

/**
 * @author Administrator
 * @date 2020-12-05 18:36
 */
public class JoinTest {

    public static void main(String[] arg) throws InterruptedException {

        Thread1 t1=new Thread1();
        Thread2 t2=new Thread2();

        t1.start();
        t2.start();
        t1.join();
        //t2.start();

        System.out.println("主线程");
    }

    public static class Thread1 extends Thread{
        @Override
        public void run() {
            try {
                Thread.sleep(2000);
            } catch (Exception e) {


            }
            sayHello(this);

        }
    }

    public static class Thread2 extends Thread{
        @Override
        public void run() {
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {


            }
            sayHello(this);

        }
    }
    public static void sayHello(Object o){
        System.out.println("公用方法"+o.getClass().getName());
    }

}
